import {Document, Schema, Model, model} from "mongoose";
import {Users} from '../types/usersType'

interface UsersDocument extends Document, Users {
}

const UsersSchema: Schema = new Schema({
    openid: { // 唯一标识，并且去重
        type: String,
        required: true
    },
    unionid: {
        type: String,
        required: true,
    },
    session_key: String,
    anonymous_openid: String,
    appid: {
        type: String,
        required: true
    },
    ips: {
        type: Array,
        default: []
    }
})

export const UsersModel: Model<UsersDocument> = model<UsersDocument>('Users', UsersSchema)